import os


JpgDir = r"G:\Temp\Temp8\merge"

NoXml = []
NoJpg = []

for root, dirs, files in os.walk(JpgDir):
    for file in files:
        if file[-1] == 'g':
            if os.path.exists(root + "\\"+file[:-3] + "xml") is False:
                NoXml.append(root+"\\"+file)

for root, dirs, files in os.walk(JpgDir):
    for file in files:
        if file[-1] == 'l':
            if os.path.exists(root + "\\"+file[:-3] + "jpg") is False:
                NoJpg.append(root+"\\"+file)
if len(NoXml) == 0:
    print("All jpg are labeled")
else:
    print("%d unlabeled" % len(NoXml))
    print(NoXml)

if len(NoJpg) == 0:
    print("All xml have a jpg")
else:
    print("%d xmls have no jpg" % len(NoJpg))
    print(NoJpg)
